package com.das.mechanic_webview.presenter.report;

import com.das.mechanic_base.base.X3BasePresenter;
import com.das.mechanic_base.mapi.api.NetWorkHttp;
import com.das.mechanic_base.mapi.response.HttpCallBack;
import com.das.mechanic_base.mapi.schedulers.RxSchedulersHelper;
import com.das.mechanic_webview.contract.report.X3SendReprotContract;

public class X3SendReportPresenter extends X3BasePresenter<X3SendReprotContract.View> implements X3SendReprotContract.Presenter {

    @Override
    public void sendReport(long workBaseId, String mobile) {
        NetWorkHttp.getApi().sendReport(mobile,workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Object>() {
                    @Override
                    protected void onDone(Object o) {
                        mView.sendSuccess();
                    }

                    @Override
                    protected String LoadingMessage() {
                        return null;
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }

    @Override
    public void sendWorkReport(long workBaseId, String mobile) {
        NetWorkHttp.getApi().sendWorkReport(mobile,workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<Object>() {
                    @Override
                    protected void onDone(Object o) {
                        mView.sendSuccess();
                    }

                    @Override
                    protected String LoadingMessage() {
                        return null;
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }

    @Override
    public void getCarOwnerMobile(long workBaseId) {

        NetWorkHttp.getApi().getCarOwnerUserMobile(workBaseId)
                .compose(RxSchedulersHelper.defaultComposeRequest())
                .compose(mView.bindToLife())
                .subscribe(new HttpCallBack<String>() {
                    @Override
                    protected void onDone(String mobile) {
                        mView.getCarOwnerMobileSuccess(mobile);
                    }

                    @Override
                    protected String LoadingMessage() {
                        return null;
                    }

                    @Override
                    protected void showError(String error) {

                    }
                });
    }
}
